<?php
/**
 * Classe FORM da tabela EMPRESA
 * 
 * @author			Mário R. Castro
 * @copyright		Voitech Sistema
 * @package			SEMAS
 * @subpackage		semas.application.controller
 * @version			1.0
*/
class App_Form_Empresa extends Voitech_Form
{
	public function __construct($options=array())
	{
		parent::__construct($options);
		
		$this->setAttribs(array('name'=>'frmCadastroEmpresa', 'id'=>'frmCadastroEmpresa', 'class'=>'form last-child'));
		
		// add id element
        $this->addElement('hidden', 'co_empresa');
        
        // remove id's decorators
        $this->getElement('co_empresa')
            ->removeDecorator('DtDdWrapper')
            ->removeDecorator('HtmlTag')
            ->removeDecorator('Label');
		
		$noPessoa 	= new Zend_Form_Element_Text( 'no_empresa' );
		$noPessoa->setLabel( 'Nome Empresa:' )
				 ->setAttribs( array('size'=>'70','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( true );
		$this->addElement( $noPessoa );				
                
		$nuCpf 	= new Zend_Form_Element_Text( 'nu_cnpj' );
		$nuCpf->setLabel( 'CNPJ:' )
				 ->setAttribs( array('size'=>'22','maxlength'=>'14','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'14', 'max'=>'20' ) ) )
		         ->setDecorators( $this->_decoratorDefault );
		$this->addElement( $nuCpf );		

		$noEndereco 	= new Zend_Form_Element_Text( 'no_endereco_empresa' );
		$noEndereco->setLabel( 'Endereço:' )
				 ->setAttribs( array('size'=>'70','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
		         ->setDecorators( $this->_decoratorDefault );
		$this->addElement( $noEndereco );	

		$noComple 	= new Zend_Form_Element_Text( 'no_complemento_empresa' );
		$noComple->setLabel( 'Complemento:' )
				 ->setAttribs( array('size'=>'38','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
		         ->setDecorators( $this->_decoratorLeft );
		$this->addElement( $noComple );	

		$noBairro 	= new Zend_Form_Element_Text( 'no_bairro_empresa' );
		$noBairro->setLabel( 'Bairro:' )
				 ->setAttribs( array('size'=>'25','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
		         ->setDecorators( $this->_decoratorDefault );
		$this->addElement( $noBairro );	

		$obParamUfRepositorio = new App_Model_ParamUfRepository();
        $selectBox = new Zend_Form_Element_Select( 'sg_uf_empresa' );
            $selectBox->setLabel('UF:');
            $selectBox->setAttribs( array('class'=> 'last-child' ) );
            $selectBox->setDecorators( $this->_decoratorLeft );
            $selectBox->addMultiOptions( Voitech_Util::converteModeloArrayCombo($obParamUfRepositorio->listarTodos(array('st_ativo'=>'S'))
                                            , 'SgUf', 'SgUf', true) );
            $selectBox->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $selectBox );

        $selectBox = new Zend_Form_Element_Select( 'co_cidade_empresa' );
            $selectBox->setLabel('Cidade:');
            $selectBox->setAttribs( array('class'=> 'last-child' ) );
            $selectBox->setDecorators( $this->_decoratorDefault );
            $selectBox->addMultiOptions( array() );
            $selectBox->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $selectBox );		


		
		$this->addDisplayGroup(array('co_empresa','no_empresa','nu_cnpj','no_endereco_empresa','no_complemento_empresa','no_bairro_empresa','sg_uf_empresa','co_cidade_empresa'),'Cadastro',array('legend' => 'Dados Empresa', 'class'=>'grey-bg first-child last-child fieldset-with-legend fieldset-with-legend-first-child'));
	}
}